<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('合同阶段表列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>合同编号：</p>
                                <input id="contractId" name="contractId" type="hidden"/>
                                <input id="contractNo" class="form-control" type="text" onclick="selectContractTree()" readonly="true">
                                <span class="input-group-addon"><i class="fa fa-search"></i></span>
                            </li>
                            <li>
                                <p>阶段序号：</p>
                                <input type="text" name="stageNo"/>
                            </li>
                            <li>
                                <p>阶段名称：</p>
                                <input type="text" name="stageName"/>
                            </li>
                            <li>
                                <p>阶段负责人一：</p>
                                <input type="text" name="stagePrincipal1"/>
                            </li>
                            <li>
                                <p>阶段负责人二：</p>
                                <input type="text" name="stagePrincipal2"/>
                            </li>
                            <li class="select-time">
                                <p>合同工期开始时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginContractStartTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endContractStartTime]"/>
                            </li>
                            <li class="select-time">
                                <p>合同工期结束时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginContractEndTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endContractEndTime]"/>
                            </li>
                            <li class="select-time">
                                <p>销售计划开始时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginBudgetStartTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endBudgetStartTime]"/>
                            </li>
                            <li class="select-time">
                                <p>销售计划结束时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginBudgetEndTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endBudgetEndTime]"/>
                            </li>
                            <li class="select-time">
                                <p>实施预测开始时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPredictStartTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPredictStartTime]"/>
                            </li>
                            <li class="select-time">
                                <p>实施预测结束时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPredictEndTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPredictEndTime]"/>
                            </li>
                            <li class="select-time">
                                <p>交付实际开始时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginActualStartTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endActualStartTime]"/>
                            </li>
                            <li class="select-time">
                                <p>交付实际结束时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginActualEndTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endActualEndTime]"/>
                            </li>
                            <li>
                                <p>本阶段合同收款金额：</p>
                                <input type="text" name="stageMoney"/>
                            </li>
                            <li class="select-time">
                                <p>本阶段合同收款时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginStageCollectionTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endStageCollectionTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:stage:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:stage:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:stage:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:stage:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:stage:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:stage:remove')}]];
        var prefix = ctx + "system/stage";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "合同阶段表",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'stageId', 
                    title : 'id',
                    visible: false
                },
                {
                    field : 'contractId', 
                    title : '合同id'
                },
                {
                    field : 'stageNo', 
                    title : '阶段序号'
                },
                {
                    field : 'stageName', 
                    title : '阶段名称'
                },
                {
                    field : 'stagePrincipal1', 
                    title : '阶段负责人一'
                },
                {
                    field : 'stagePrincipal2', 
                    title : '阶段负责人二'
                },

                {
                    field : 'stageMoney', 
                    title : '本阶段合同收款金额'
                },
                {
                    field : 'stageCollectionTime', 
                    title : '本阶段合同收款时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.stageId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.stageId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        /*合同阶段-新增-选择合同树*/
        function selectContractTree() {
            var alpContractDetail = [[${alpContractDetail}]];
            if(alpContractDetail == null || alpContractDetail == undefined) {
                var options = {
                    title: '合同选择',
                    width: "500",
                    url: prefix + "/selectContractTree",
                    callBack: doSubmit
                };
                $.modal.openOptions(options);
            } else {
                return;
            }
        }
        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            $("#contractId").val(body.find('#contractId').val());
            $("#contractNo").val(body.find('#contractNo').val());
            layer.close(index);
        }
    </script>
</body>
</html>